#! /usr/bin/env python
# encoding=utf-8

from xml.sax import parseString
from xml.sax.handler import ContentHandler
from urllib import urlopen
 
class Handler(ContentHandler):
	def __init__(self):
		self.name = [False, None]
		self.location = [False, None]
		self.url = [False, None]
		self.text = False
	
	def startElement(self, name, attrs):
		if name == 'name':
			self.name[0] = True
		elif name == 'location':
			self.location[0] = True
		elif name == 'url':
			self.url[0] == True
		elif name == 'text':
			self.text = True
	
	def characters(self, content):
		if self.name[0]:
			self.name = [False, content]
		elif self.location[0]:
			self.location = [False, content]
		elif self.url[0]:
			self.url = [False, content]
		elif self.text:
			self.text = False
			print self.name[1], '|', self.location[1], '|', self.url[1]
			print 'Status:', content
			print

url = 'https://api.twitter.com/1/statuses/friends/enchufa2.xml'
content = urlopen(url).read()
parser = parseString(content, Handler())